![]() |
Panel の上で右クリックして、カスタムスタイル編集を開いた画面
![]() |
|
アイコン(256,256)の画像(PNG,BMP..)をPixelFormer(アイコン作成ソフト)で256,256のアイコンに変換する目的で作ったソフトで ソ−ス フアイルをImage1に読み込み、リサイズした画像をImage2に表示、保存でImage2の画像を保存するだけのもので、 リサイズはソースの画像の縦横比を無視し、設定したサイズにします。 リサイズは DrawBitmap()を利用しております。 カスタムスタイル編集は、Panelにマウスを持っていき、右クリックで、上の右の図でカスタムスタイル編集の項目が出てきます。Form,Buttonなどの背景色 の設定は出来ないようでした? |
|
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
//---------------------------------------------------------------------------
TBitmap *bmp;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MenuItem1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MenuItem3Click(TObject *Sender) //open file
{
delete bmp;
bmp = new Graphics::TBitmap();
if(OpenDialog1->Execute())
{
bmp->LoadFromFile(OpenDialog1->FileName);
Image1->Bitmap=bmp;
String a=bmp->Width;
String b=bmp->Height;
Label5->Text=OpenDialog1->FileName;
Label6->Text=a+" x "+b+" dot";
Button1->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MenuItem4Click(TObject *Sender)
{
if(Form1->SaveDialog1->Execute())
{
Image2->Bitmap->SaveToFile(SaveDialog1->FileName);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRectF srcR,distR;
Single w,h;
w=Edit1->Text.ToDouble();
h=Edit2->Text.ToDouble();
TBitmap *tmp=new TBitmap (w,h);
Image2->Bitmap=tmp;
delete tmp;
srcR=TRectF(0,0,bmp->Width,bmp->Height);
distR=TRectF(0,0,w,h);
Image2->Bitmap->Canvas->BeginScene();
Image2->Bitmap->Canvas->DrawBitmap(bmp,srcR,distR,1,false);
Image2->Bitmap->Canvas->EndScene();
}
//---------------------------------------------------------------------------